package com.example.transactionhintassistant.config;

import com.example.transactionhintassistant.interceptor.LoginProtectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginProtectInterceptor loginProtectInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginProtectInterceptor).addPathPatterns("/**")
                .excludePathPatterns(
                        "/webjars/**",
                        "/doc.html/**",
                        "/v3/api-docs/**",
                        "/static/**",
                        "/auth/**",
                        "/email/captcha/bindingEmail/**",
                        "/email/captcha/login/**",
                        "/memos/delete/**",
                        "/weekly-plan/change-name/**",
                        "/weekly-plan/delete/**"
                );
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
